<template>
	<view class="" v-if="info.id">

		
		
		<view>
		
			<u-swiper @change="bannerChange" @click="toBanner(curBanner)" name="picUrl" :list="info.sliderPicUrls"
				height="220">
			</u-swiper>
		</view>
		
		<view class="module-btn">
			<view class="u-flex u-f-jsb btn btn-cart">
				￥200<span>加入购物车</span>
			</view>
			<view class="u-flex u-f-jsb btn btn-buy">
				￥200<span>立即购买</span>
			</view>
		</view>


		<view class="fixed-bottom">
			<view class="u-flex u-f-jsb bt pt10 pl20 pr20" style="text-align: center;">
				<view>
					<u-icon name="edit-pen"></u-icon>
					<view>编辑</view>
				</view>
				<view>
					<u-icon name="star"></u-icon>
					<view>收藏</view>
				</view>
				<view>
					<u-icon name="zhuanfa"></u-icon>
					<view>发布分享</view>
				</view>
				<view>
					<u-icon name="shopping-cart"></u-icon>
					<view>购物车</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import PSD from 'psd';
	export default {
		data() {
			return {
				info: {},

			}
		},

		onLoad(e) {
			e.id = 21
			this.getInfo(e.id)
			console.log(PSD,1111111111)
		},
		onShow() {},

		methods: {
			getInfo(id) {
				this.$api.productInfo({
					id
				}, res => {
					if (res.code == 200) {
						this.info = res.data
					}
				})
			},


			addCart: function(e) { //加入购物车
				if (!this.curSku.id) {
					uni.showToast({
						title: '请选择规格',
						icon: 'none'
					});
					return
				}
				this.$api.cartAdd({
					skuId: this.curSku.id,
					count: this.skuNum
				}, res => {
					if (res.code == 200) {

						uni.showToast({
							title: '添加成功',
							icon: 'none'
						});
					} else {

						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					}
				})
			},
			buyNow: function() { //立即购买

				if (!this.curSku.id) {
					uni.showToast({
						title: '请选择规格',
						icon: 'none'
					});
					return
				}
				this.$api.buyNow({
					skuId: this.curSku.id,
					count: this.skuNum
				}, res => {
					if (res.code == 200) {
						let ids = res.data
						this.$api.orderCheckSettlement({
							cartIds: ids,
						}, res => {
							if (res.code == 200) {

								uni.navigateTo({
									url: '/pages/product/confirm?cartIds=' + ids
								})
							} else {

								uni.showToast({
									title: res.msg,
									icon: 'none'
								});
							}
						})

					} else {

						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				})

			},
		}
	}
</script>

<style lang="scss">
	.module-btn{
		padding: 40rpx;
		.btn{
			background: #70B52C;
			border-radius: 16rpx;
			padding: 24rpx;
			font-size: 28rpx;
			color: #fff;
			margin-top: 24rpx;
		}
		.btn-buy{
			background: #2C9942;
		}
	}
</style>